{
 "metadata": {
  "signature": "sha256:6a0d87c0286ee4da39c6ff0e5eee67a824a84cefe7a7f6023b9ceef3114d20bb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "FE103231B3E9488BB8648C105FF1B434",
     "input": [
      "import numpy as np\n",
      "import pandas as pd\n",
      "import itertools\n",
      "from datetime import datetime\n",
      "from dateutil.parser import parse\n",
      "from scipy import stats as ss\n",
      "import matplotlib.pyplot as plt\n",
      "import seaborn as sn\n",
      "sn.set_style('white')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "id": "C884D785385542A490145351F4FB6692",
     "metadata": {},
     "source": [
      "## 1. \u8ba1\u7b97\u6708\u5ea6\u884c\u4e1a\u6536\u76ca\u7387\n",
      "---\n",
      "\u76ee\u524d\u4ec5\u63d0\u4f9b\u6307\u6570\u65e5\u7ebf\u884c\u60c5\uff0c\u6545\u6211\u4eec\u8981\u5c06\u65e5\u7ebf\u884c\u60c5\u8f6c\u5316\u4e3a\u6708\u7ebf\u884c\u4e1a\u3002"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "7891CA62D52E4422A32A19A6A7EB3CC2",
     "input": [
      "\n",
      "def get_sw_ind_quotation():\n",
      "    \n",
      "    \"\"\"\n",
      "    \u8fd4\u56de\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6307\u6570\u6240\u6709\u5386\u53f2\u884c\u60c5\n",
      "    Args:\n",
      "        opt(bool):\u9009\u62e9\u662f\u5426\u5254\u9664\u7efc\u5408\u884c\u4e1a\uff0c\u9ed8\u8ba4\u4e0d\u5254\u9664\n",
      "    Returns:\n",
      "        DataFrame: \u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6307\u6570\u65e5\u7ebf\u884c\u60c5\n",
      "\n",
      "    Examples:\n",
      "        >> df_daily_industry_unstack  = get_sw_ind_quotation()\n",
      "    \"\"\"\n",
      "    \n",
      "    # \u62ff\u53d6\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6307\u6570\u4ee3\u7801\uff0c\u4e00\u517128\u4e2a\n",
      "    index_symbol = DataAPI.IndustryGet(industryVersion=u\"SW\",industryVersionCD=u\"\",industryLevel=u\"1\",isNew=u\"1\",field=u\"\",pandas=\"1\")['indexSymbol'].tolist() \n",
      "\n",
      "    index_symbol = [str(item) + '.ZICN' for item in index_symbol]  # \u52a0\u4e0a\u540e\u7f00\uff0c\u4f7f\u5f97\u4e0b\u9762\u7684\u884c\u60c5API\u53ef\u4ee5\u8c03\u7528\n",
      "    symbol_history_list = [] \n",
      "    for symbol in index_symbol: # \u8be5API\u6bcf\u6b21\u53ea\u80fd\u8c03\u7528\u4e00\u4e2aindexID\n",
      "        df_daily_industry_symbol = DataAPI.MktIdxdGet(beginDate='2015-01-01', endDate='2018-01-23', ticker=symbol[:6], field=u\"ticker,tradeDate,closeIndex\")\n",
      "        symbol_history_list.append(df_daily_industry_symbol)\n",
      "        \n",
      "    df_daily_industry_symbol = pd.concat(symbol_history_list,axis=0)  # \u5c06\u83b7\u53d6\u7684\u884c\u4e1a\u6570\u636e\u6c47\u603b\n",
      "    df_daily_industry_unstack = df_daily_industry_symbol.set_index(['tradeDate','ticker']).unstack()['closeIndex'] # \u5c06\u6240\u6709\u7684\u884c\u4e1a\u884c\u60c5\u6570\u636e\u8f6c\u5316\u4e3a\u4e00\u5f20\u4e8c\u7ef4\u8868\n",
      "    return df_daily_industry_unstack"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "9628D159899043B3B37FEF8F8C7AD7EB",
     "input": [
      "df_daily_industry_unstack = get_sw_ind_quotation() "
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "973A38F5E17542AA8DDD988E2782073A",
     "input": [
      "df_daily_industry_unstack.head() # \u5982\u4e0a\u6211\u4eec\u4fbf\u5f97\u5230\u4e86\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u81f3\u4eca\u7684\u884c\u60c5\u6570\u636e"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th>ticker</th>\n",
        "      <th>801010</th>\n",
        "      <th>801020</th>\n",
        "      <th>801030</th>\n",
        "      <th>801040</th>\n",
        "      <th>801050</th>\n",
        "      <th>801080</th>\n",
        "      <th>801110</th>\n",
        "      <th>801120</th>\n",
        "      <th>801130</th>\n",
        "      <th>801140</th>\n",
        "      <th>...</th>\n",
        "      <th>801720</th>\n",
        "      <th>801730</th>\n",
        "      <th>801740</th>\n",
        "      <th>801750</th>\n",
        "      <th>801760</th>\n",
        "      <th>801770</th>\n",
        "      <th>801780</th>\n",
        "      <th>801790</th>\n",
        "      <th>801880</th>\n",
        "      <th>801890</th>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>tradeDate</th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>2015-01-05</th>\n",
        "      <td>2236.45</td>\n",
        "      <td>3948.24</td>\n",
        "      <td>2363.95</td>\n",
        "      <td>2867.48</td>\n",
        "      <td>3525.56</td>\n",
        "      <td>2050.59</td>\n",
        "      <td>3827.48</td>\n",
        "      <td>5754.81</td>\n",
        "      <td>2232.03</td>\n",
        "      <td>2119.34</td>\n",
        "      <td>...</td>\n",
        "      <td>2849.47</td>\n",
        "      <td>4473.75</td>\n",
        "      <td>1484.44</td>\n",
        "      <td>3364.19</td>\n",
        "      <td>1021.55</td>\n",
        "      <td>2016.73</td>\n",
        "      <td>3487.86</td>\n",
        "      <td>2384.07</td>\n",
        "      <td>4141.25</td>\n",
        "      <td>1342.11</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-01-06</th>\n",
        "      <td>2268.86</td>\n",
        "      <td>3913.17</td>\n",
        "      <td>2386.62</td>\n",
        "      <td>2815.31</td>\n",
        "      <td>3500.72</td>\n",
        "      <td>2101.89</td>\n",
        "      <td>3939.99</td>\n",
        "      <td>5761.53</td>\n",
        "      <td>2255.31</td>\n",
        "      <td>2150.17</td>\n",
        "      <td>...</td>\n",
        "      <td>2842.41</td>\n",
        "      <td>4592.41</td>\n",
        "      <td>1544.21</td>\n",
        "      <td>3489.33</td>\n",
        "      <td>1064.18</td>\n",
        "      <td>2065.44</td>\n",
        "      <td>3452.59</td>\n",
        "      <td>2341.66</td>\n",
        "      <td>4258.60</td>\n",
        "      <td>1367.09</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-01-07</th>\n",
        "      <td>2276.33</td>\n",
        "      <td>3941.72</td>\n",
        "      <td>2399.02</td>\n",
        "      <td>2837.07</td>\n",
        "      <td>3559.94</td>\n",
        "      <td>2085.99</td>\n",
        "      <td>3925.32</td>\n",
        "      <td>5675.26</td>\n",
        "      <td>2256.28</td>\n",
        "      <td>2164.55</td>\n",
        "      <td>...</td>\n",
        "      <td>2855.39</td>\n",
        "      <td>4607.16</td>\n",
        "      <td>1521.46</td>\n",
        "      <td>3482.27</td>\n",
        "      <td>1053.78</td>\n",
        "      <td>2065.88</td>\n",
        "      <td>3405.26</td>\n",
        "      <td>2388.10</td>\n",
        "      <td>4234.47</td>\n",
        "      <td>1378.43</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-01-08</th>\n",
        "      <td>2291.92</td>\n",
        "      <td>3881.47</td>\n",
        "      <td>2399.28</td>\n",
        "      <td>2753.14</td>\n",
        "      <td>3472.51</td>\n",
        "      <td>2089.58</td>\n",
        "      <td>3912.41</td>\n",
        "      <td>5686.32</td>\n",
        "      <td>2259.70</td>\n",
        "      <td>2161.37</td>\n",
        "      <td>...</td>\n",
        "      <td>2734.98</td>\n",
        "      <td>4599.74</td>\n",
        "      <td>1510.24</td>\n",
        "      <td>3509.65</td>\n",
        "      <td>1054.65</td>\n",
        "      <td>2070.45</td>\n",
        "      <td>3279.05</td>\n",
        "      <td>2309.90</td>\n",
        "      <td>4223.97</td>\n",
        "      <td>1374.91</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-01-09</th>\n",
        "      <td>2261.17</td>\n",
        "      <td>3812.96</td>\n",
        "      <td>2370.28</td>\n",
        "      <td>2719.27</td>\n",
        "      <td>3428.33</td>\n",
        "      <td>2086.54</td>\n",
        "      <td>3856.32</td>\n",
        "      <td>5646.34</td>\n",
        "      <td>2243.61</td>\n",
        "      <td>2147.17</td>\n",
        "      <td>...</td>\n",
        "      <td>2730.34</td>\n",
        "      <td>4543.52</td>\n",
        "      <td>1485.78</td>\n",
        "      <td>3544.91</td>\n",
        "      <td>1056.12</td>\n",
        "      <td>2049.64</td>\n",
        "      <td>3312.14</td>\n",
        "      <td>2323.46</td>\n",
        "      <td>4180.71</td>\n",
        "      <td>1373.51</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "<p>5 rows \u00d7 28 columns</p>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 86,
       "text": [
        "ticker       801010   801020   801030   801040   801050   801080   801110  \\\n",
        "tradeDate                                                                   \n",
        "2015-01-05  2236.45  3948.24  2363.95  2867.48  3525.56  2050.59  3827.48   \n",
        "2015-01-06  2268.86  3913.17  2386.62  2815.31  3500.72  2101.89  3939.99   \n",
        "2015-01-07  2276.33  3941.72  2399.02  2837.07  3559.94  2085.99  3925.32   \n",
        "2015-01-08  2291.92  3881.47  2399.28  2753.14  3472.51  2089.58  3912.41   \n",
        "2015-01-09  2261.17  3812.96  2370.28  2719.27  3428.33  2086.54  3856.32   \n",
        "\n",
        "ticker       801120   801130   801140   ...      801720   801730   801740  \\\n",
        "tradeDate                               ...                                 \n",
        "2015-01-05  5754.81  2232.03  2119.34   ...     2849.47  4473.75  1484.44   \n",
        "2015-01-06  5761.53  2255.31  2150.17   ...     2842.41  4592.41  1544.21   \n",
        "2015-01-07  5675.26  2256.28  2164.55   ...     2855.39  4607.16  1521.46   \n",
        "2015-01-08  5686.32  2259.70  2161.37   ...     2734.98  4599.74  1510.24   \n",
        "2015-01-09  5646.34  2243.61  2147.17   ...     2730.34  4543.52  1485.78   \n",
        "\n",
        "ticker       801750   801760   801770   801780   801790   801880   801890  \n",
        "tradeDate                                                                  \n",
        "2015-01-05  3364.19  1021.55  2016.73  3487.86  2384.07  4141.25  1342.11  \n",
        "2015-01-06  3489.33  1064.18  2065.44  3452.59  2341.66  4258.60  1367.09  \n",
        "2015-01-07  3482.27  1053.78  2065.88  3405.26  2388.10  4234.47  1378.43  \n",
        "2015-01-08  3509.65  1054.65  2070.45  3279.05  2309.90  4223.97  1374.91  \n",
        "2015-01-09  3544.91  1056.12  2049.64  3312.14  2323.46  4180.71  1373.51  \n",
        "\n",
        "[5 rows x 28 columns]"
       ]
      }
     ]
    },
    {
     "cell_type": "markdown",
     "id": "E644AE48D0044E3EBA53F8DFBB584187",
     "metadata": {},
     "source": [
      "\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8981\u5c06\u65e5\u7ebf\u7684\u884c\u60c5\u6570\u636e\uff0c\u8f6c\u5316\u4e3a\u5468\u7ebf\u7684\u884c\u60c5\u6570\u636e\uff0c\u56e0\u4e3a\u7b2c\u4e00\u5929\u7684\u884c\u60c5\uff0c\u6709\u7684\u884c\u4e1a\u5b58\u5728\u7f3a\u5931\u503c\uff0c\u6545\u6211\u4eec\u5c06\u7b2c\u4e00\u5929\u7684\u884c\u60c5\u5254\u9664\u3002\u5b9a\u4e49\u6708\u884c\u60c5\u4e3a\u6bcf\u6708\u7684\u7b2c\u4e00\u4e2a\u4ea4\u6613\u65e5\u5230\u4e0b\u4e00\u6708\u7684\u7b2c\u4e00\u4e2a\u4ea4\u6613\u65e5\u3002"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "138DDAF2482D401C8E9F7C974729F8F5",
     "input": [
      "df_daily_industry_unstack = df_daily_industry_unstack.iloc[1:]  # \u53bb\u6389\u7b2c\u4e00\u671f\u57fa\u671f\n",
      "df_daily_industry_unstack['tradeDate'] = df_daily_industry_unstack.index  # \u52a0\u5165tradeDate\u5217\uff0c\u65b9\u4fbf\u505amap"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "22CFEB780AE74071B0776D442C79C387",
     "input": [
      "def getMonthlyIndex(df_index):  # \u5f97\u5230\u6708\u7ebf\u884c\u60c5\n",
      "    df_index['tradeDate'] = df_index['tradeDate'].map(lambda x:parse(x)) # \u5c06tradeDate\u5217\u8f6c\u5316\u4e3a\u65f6\u95f4\u683c\u5f0f\n",
      "    df_index['year_month'] = df_index['tradeDate'].map(lambda x:(x.year,x.month)) # \u5f97\u5230\uff08\u5e74\uff0c\u6708\uff09\u7528\u4e8e\u7b5b\u9009\n",
      "    return df_index.groupby(['year_month']).head(1) # \u8fd4\u56de\u6bcf\u4e2a\u6708\u7684\u7b2c\u4e00\u4e2a\u4ea4\u6613\u65e5\u884c\u60c5"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "439BB6E1E6054B1F912EB4F9339BBBB7",
     "input": [
      "df_monthly_industry_unstack = getMonthlyIndex(df_daily_industry_unstack[:])\n",
      "df_monthly_industry_unstack = df_monthly_industry_unstack.sort_values(['tradeDate']) # \u6309tradeDate\u5217\u6392\u5e8f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "22FD24314B904D49BFCD3E90E8BB4914",
     "input": [
      "df_monthly_industry_unstack.head(5) # \u5982\u4e0a\u6211\u4eec\u4fbf\u5f97\u5230\u4e86\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6bcf\u4e2a\u6708\u7b2c\u4e00\u4e2a\u4ea4\u6613\u65e5\u7684\u884c\u60c5\u6570\u636e"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th>ticker</th>\n",
        "      <th>801010</th>\n",
        "      <th>801020</th>\n",
        "      <th>801030</th>\n",
        "      <th>801040</th>\n",
        "      <th>801050</th>\n",
        "      <th>801080</th>\n",
        "      <th>801110</th>\n",
        "      <th>801120</th>\n",
        "      <th>801130</th>\n",
        "      <th>801140</th>\n",
        "      <th>...</th>\n",
        "      <th>801740</th>\n",
        "      <th>801750</th>\n",
        "      <th>801760</th>\n",
        "      <th>801770</th>\n",
        "      <th>801780</th>\n",
        "      <th>801790</th>\n",
        "      <th>801880</th>\n",
        "      <th>801890</th>\n",
        "      <th>tradeDate</th>\n",
        "      <th>year_month</th>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>tradeDate</th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>2015-01-06</th>\n",
        "      <td>2268.86</td>\n",
        "      <td>3913.17</td>\n",
        "      <td>2386.62</td>\n",
        "      <td>2815.31</td>\n",
        "      <td>3500.72</td>\n",
        "      <td>2101.89</td>\n",
        "      <td>3939.99</td>\n",
        "      <td>5761.53</td>\n",
        "      <td>2255.31</td>\n",
        "      <td>2150.17</td>\n",
        "      <td>...</td>\n",
        "      <td>1544.21</td>\n",
        "      <td>3489.33</td>\n",
        "      <td>1064.18</td>\n",
        "      <td>2065.44</td>\n",
        "      <td>3452.59</td>\n",
        "      <td>2341.66</td>\n",
        "      <td>4258.60</td>\n",
        "      <td>1367.09</td>\n",
        "      <td>2015-01-06</td>\n",
        "      <td>(2015, 1)</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-02-02</th>\n",
        "      <td>2408.42</td>\n",
        "      <td>3508.26</td>\n",
        "      <td>2465.82</td>\n",
        "      <td>2728.11</td>\n",
        "      <td>3432.93</td>\n",
        "      <td>2247.57</td>\n",
        "      <td>3915.61</td>\n",
        "      <td>5410.83</td>\n",
        "      <td>2410.22</td>\n",
        "      <td>2275.72</td>\n",
        "      <td>...</td>\n",
        "      <td>1558.32</td>\n",
        "      <td>4049.61</td>\n",
        "      <td>1174.67</td>\n",
        "      <td>2134.60</td>\n",
        "      <td>2978.83</td>\n",
        "      <td>2071.26</td>\n",
        "      <td>4231.80</td>\n",
        "      <td>1390.32</td>\n",
        "      <td>2015-02-02</td>\n",
        "      <td>(2015, 2)</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-03-02</th>\n",
        "      <td>2532.27</td>\n",
        "      <td>3710.69</td>\n",
        "      <td>2666.77</td>\n",
        "      <td>3014.07</td>\n",
        "      <td>3697.56</td>\n",
        "      <td>2459.35</td>\n",
        "      <td>4332.34</td>\n",
        "      <td>5665.28</td>\n",
        "      <td>2634.79</td>\n",
        "      <td>2515.53</td>\n",
        "      <td>...</td>\n",
        "      <td>1648.81</td>\n",
        "      <td>4856.21</td>\n",
        "      <td>1374.92</td>\n",
        "      <td>2454.54</td>\n",
        "      <td>3048.01</td>\n",
        "      <td>2289.72</td>\n",
        "      <td>4694.78</td>\n",
        "      <td>1518.45</td>\n",
        "      <td>2015-03-02</td>\n",
        "      <td>(2015, 3)</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-04-01</th>\n",
        "      <td>3092.02</td>\n",
        "      <td>4275.90</td>\n",
        "      <td>3155.33</td>\n",
        "      <td>3477.40</td>\n",
        "      <td>4268.23</td>\n",
        "      <td>2978.90</td>\n",
        "      <td>4986.37</td>\n",
        "      <td>6378.81</td>\n",
        "      <td>3297.86</td>\n",
        "      <td>3098.43</td>\n",
        "      <td>...</td>\n",
        "      <td>1864.25</td>\n",
        "      <td>6220.21</td>\n",
        "      <td>1625.64</td>\n",
        "      <td>2922.88</td>\n",
        "      <td>3371.20</td>\n",
        "      <td>2584.91</td>\n",
        "      <td>5430.15</td>\n",
        "      <td>1858.32</td>\n",
        "      <td>2015-04-01</td>\n",
        "      <td>(2015, 4)</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-05-04</th>\n",
        "      <td>3455.63</td>\n",
        "      <td>4972.64</td>\n",
        "      <td>3629.54</td>\n",
        "      <td>4304.91</td>\n",
        "      <td>4836.34</td>\n",
        "      <td>3291.82</td>\n",
        "      <td>5702.31</td>\n",
        "      <td>7444.05</td>\n",
        "      <td>3853.45</td>\n",
        "      <td>3644.14</td>\n",
        "      <td>...</td>\n",
        "      <td>2454.86</td>\n",
        "      <td>6881.28</td>\n",
        "      <td>1956.72</td>\n",
        "      <td>3450.91</td>\n",
        "      <td>3782.19</td>\n",
        "      <td>2796.30</td>\n",
        "      <td>6057.83</td>\n",
        "      <td>2261.53</td>\n",
        "      <td>2015-05-04</td>\n",
        "      <td>(2015, 5)</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "<p>5 rows \u00d7 30 columns</p>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 90,
       "text": [
        "ticker       801010   801020   801030   801040   801050   801080   801110  \\\n",
        "tradeDate                                                                   \n",
        "2015-01-06  2268.86  3913.17  2386.62  2815.31  3500.72  2101.89  3939.99   \n",
        "2015-02-02  2408.42  3508.26  2465.82  2728.11  3432.93  2247.57  3915.61   \n",
        "2015-03-02  2532.27  3710.69  2666.77  3014.07  3697.56  2459.35  4332.34   \n",
        "2015-04-01  3092.02  4275.90  3155.33  3477.40  4268.23  2978.90  4986.37   \n",
        "2015-05-04  3455.63  4972.64  3629.54  4304.91  4836.34  3291.82  5702.31   \n",
        "\n",
        "ticker       801120   801130   801140     ...       801740   801750   801760  \\\n",
        "tradeDate                                 ...                                  \n",
        "2015-01-06  5761.53  2255.31  2150.17     ...      1544.21  3489.33  1064.18   \n",
        "2015-02-02  5410.83  2410.22  2275.72     ...      1558.32  4049.61  1174.67   \n",
        "2015-03-02  5665.28  2634.79  2515.53     ...      1648.81  4856.21  1374.92   \n",
        "2015-04-01  6378.81  3297.86  3098.43     ...      1864.25  6220.21  1625.64   \n",
        "2015-05-04  7444.05  3853.45  3644.14     ...      2454.86  6881.28  1956.72   \n",
        "\n",
        "ticker       801770   801780   801790   801880   801890  tradeDate  year_month  \n",
        "tradeDate                                                                       \n",
        "2015-01-06  2065.44  3452.59  2341.66  4258.60  1367.09 2015-01-06   (2015, 1)  \n",
        "2015-02-02  2134.60  2978.83  2071.26  4231.80  1390.32 2015-02-02   (2015, 2)  \n",
        "2015-03-02  2454.54  3048.01  2289.72  4694.78  1518.45 2015-03-02   (2015, 3)  \n",
        "2015-04-01  2922.88  3371.20  2584.91  5430.15  1858.32 2015-04-01   (2015, 4)  \n",
        "2015-05-04  3450.91  3782.19  2796.30  6057.83  2261.53 2015-05-04   (2015, 5)  \n",
        "\n",
        "[5 rows x 30 columns]"
       ]
      }
     ]
    },
    {
     "cell_type": "markdown",
     "id": "12162C83E485472092B256CCD678EBE4",
     "metadata": {},
     "source": [
      "\u63a5\u4e0b\u6765\u6211\u4eec\u4fbf\u8981\u6c42\u6708\u5ea6\u6536\u76ca\u7387\u53ca\u5176\u6392\u540d\uff0c\u8c03\u7528`Series`\u7684\u5185\u7f6e\u51fd\u6570`pct_change()`\u53ef\u4ee5\u5f88\u65b9\u4fbf\u8ba1\u7b97\u6536\u76ca\u7387\uff1b\u6392\u540d\u8c03\u7528`rank()`\u51fd\u6570\u6309\u884c\u505a\u6392\u5e8f\u5c31\u5c31\u53ef\u4ee5\u4e86\uff0c\u9ed8\u8ba4\u4ece\u5c0f\u5230\u5927\u3002"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "2EEA719EA594411C933823C9D8DD24BC",
     "input": [
      "del df_monthly_industry_unstack['tradeDate'] # \u5220\u9664tradeDate\u5217\u548cyear_month\u5217\uff0c\u65b9\u4fbf\u540e\u9762\u8c03\u7528\u540e\u7f00\u51fd\u6570\u8ba1\u7b97\u884c\u4e1a\u6536\u76ca\u7387\n",
      "del df_monthly_industry_unstack['year_month']"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "A43F4E2E54B140A8879590A7643FAA38",
     "input": [
      "df_monthly_industry_return = df_monthly_industry_unstack.pct_change(axis=0) # \u8c03\u7528pct_change()\u8ba1\u7b97\u6536\u76ca\u7387\n",
      "df_monthly_industry_return = df_monthly_industry_return.dropna(how='all') # \u5220\u9664\u5168\u662f\u7f3a\u5931\u503c\u7684\u7b2c\u4e00\u884c\n",
      "df_monthly_industry_return_rank = df_monthly_industry_return.rank(axis=1) # \u6309\u884c\u505a\u6392\u5e8f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "43D69FAD5D6046D7A701AC2D580147E2",
     "input": [
      "df_monthly_industry_return_rank.head(5) # \u5982\u4e0a\u6211\u4eec\u4fbf\u5f97\u5230\u4e86\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6bcf\u4e00\u671f\u6536\u76ca\u7387\u7684\u6392\u540d"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th>ticker</th>\n",
        "      <th>801010</th>\n",
        "      <th>801020</th>\n",
        "      <th>801030</th>\n",
        "      <th>801040</th>\n",
        "      <th>801050</th>\n",
        "      <th>801080</th>\n",
        "      <th>801110</th>\n",
        "      <th>801120</th>\n",
        "      <th>801130</th>\n",
        "      <th>801140</th>\n",
        "      <th>...</th>\n",
        "      <th>801720</th>\n",
        "      <th>801730</th>\n",
        "      <th>801740</th>\n",
        "      <th>801750</th>\n",
        "      <th>801760</th>\n",
        "      <th>801770</th>\n",
        "      <th>801780</th>\n",
        "      <th>801790</th>\n",
        "      <th>801880</th>\n",
        "      <th>801890</th>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>tradeDate</th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>2015-02-02</th>\n",
        "      <td>24.0</td>\n",
        "      <td>3.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>25.0</td>\n",
        "      <td>23.0</td>\n",
        "      <td>...</td>\n",
        "      <td>4.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>14.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>15.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-03-02</th>\n",
        "      <td>4.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>11.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>16.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>...</td>\n",
        "      <td>25.0</td>\n",
        "      <td>17.0</td>\n",
        "      <td>6.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>14.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-04-01</th>\n",
        "      <td>20.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>8.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>6.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>...</td>\n",
        "      <td>25.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>3.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>21.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-05-04</th>\n",
        "      <td>6.0</td>\n",
        "      <td>16.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>...</td>\n",
        "      <td>28.0</td>\n",
        "      <td>14.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>23.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-06-01</th>\n",
        "      <td>21.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>...</td>\n",
        "      <td>3.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>25.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>18.0</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "<p>5 rows \u00d7 28 columns</p>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 93,
       "text": [
        "ticker      801010  801020  801030  801040  801050  801080  801110  801120  \\\n",
        "tradeDate                                                                    \n",
        "2015-02-02    24.0     3.0    20.0     9.0    10.0    26.0    13.0     7.0   \n",
        "2015-03-02     4.0     5.0    11.0    19.0    10.0    16.0    22.0     2.0   \n",
        "2015-04-01    20.0     7.0    13.0     8.0     9.0    18.0     6.0     2.0   \n",
        "2015-05-04     6.0    16.0    15.0    24.0     9.0     2.0    13.0    18.0   \n",
        "2015-06-01    21.0     5.0    15.0     4.0    10.0    27.0    12.0     9.0   \n",
        "\n",
        "ticker      801130  801140   ...    801720  801730  801740  801750  801760  \\\n",
        "tradeDate                    ...                                             \n",
        "2015-02-02    25.0    23.0   ...       4.0    18.0    14.0    28.0    27.0   \n",
        "2015-03-02    15.0    20.0   ...      25.0    17.0     6.0    28.0    27.0   \n",
        "2015-04-01    24.0    22.0   ...      25.0    27.0     4.0    28.0    12.0   \n",
        "2015-05-04    19.0    20.0   ...      28.0    14.0    27.0     4.0    22.0   \n",
        "2015-06-01    24.0    26.0   ...       3.0    19.0    20.0    28.0    22.0   \n",
        "\n",
        "ticker      801770  801780  801790  801880  801890  \n",
        "tradeDate                                           \n",
        "2015-02-02    21.0     1.0     2.0    12.0    15.0  \n",
        "2015-03-02    26.0     1.0    21.0    24.0    14.0  \n",
        "2015-04-01    15.0     1.0     3.0    10.0    21.0  \n",
        "2015-05-04    21.0     7.0     1.0     5.0    23.0  \n",
        "2015-06-01    25.0     1.0     2.0    13.0    18.0  \n",
        "\n",
        "[5 rows x 28 columns]"
       ]
      }
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "17D7C826BC1D44D2A4B7CB7791AD0854",
     "input": [
      "df_monthly_industry_return_rank.head()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th>ticker</th>\n",
        "      <th>801010</th>\n",
        "      <th>801020</th>\n",
        "      <th>801030</th>\n",
        "      <th>801040</th>\n",
        "      <th>801050</th>\n",
        "      <th>801080</th>\n",
        "      <th>801110</th>\n",
        "      <th>801120</th>\n",
        "      <th>801130</th>\n",
        "      <th>801140</th>\n",
        "      <th>...</th>\n",
        "      <th>801720</th>\n",
        "      <th>801730</th>\n",
        "      <th>801740</th>\n",
        "      <th>801750</th>\n",
        "      <th>801760</th>\n",
        "      <th>801770</th>\n",
        "      <th>801780</th>\n",
        "      <th>801790</th>\n",
        "      <th>801880</th>\n",
        "      <th>801890</th>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>tradeDate</th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "      <th></th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>2015-02-02</th>\n",
        "      <td>24.0</td>\n",
        "      <td>3.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>25.0</td>\n",
        "      <td>23.0</td>\n",
        "      <td>...</td>\n",
        "      <td>4.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>14.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>15.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-03-02</th>\n",
        "      <td>4.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>11.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>16.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>...</td>\n",
        "      <td>25.0</td>\n",
        "      <td>17.0</td>\n",
        "      <td>6.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>14.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-04-01</th>\n",
        "      <td>20.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>8.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>6.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>...</td>\n",
        "      <td>25.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>3.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>21.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-05-04</th>\n",
        "      <td>6.0</td>\n",
        "      <td>16.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>18.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>...</td>\n",
        "      <td>28.0</td>\n",
        "      <td>14.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>21.0</td>\n",
        "      <td>7.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>23.0</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2015-06-01</th>\n",
        "      <td>21.0</td>\n",
        "      <td>5.0</td>\n",
        "      <td>15.0</td>\n",
        "      <td>4.0</td>\n",
        "      <td>10.0</td>\n",
        "      <td>27.0</td>\n",
        "      <td>12.0</td>\n",
        "      <td>9.0</td>\n",
        "      <td>24.0</td>\n",
        "      <td>26.0</td>\n",
        "      <td>...</td>\n",
        "      <td>3.0</td>\n",
        "      <td>19.0</td>\n",
        "      <td>20.0</td>\n",
        "      <td>28.0</td>\n",
        "      <td>22.0</td>\n",
        "      <td>25.0</td>\n",
        "      <td>1.0</td>\n",
        "      <td>2.0</td>\n",
        "      <td>13.0</td>\n",
        "      <td>18.0</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "<p>5 rows \u00d7 28 columns</p>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 94,
       "text": [
        "ticker      801010  801020  801030  801040  801050  801080  801110  801120  \\\n",
        "tradeDate                                                                    \n",
        "2015-02-02    24.0     3.0    20.0     9.0    10.0    26.0    13.0     7.0   \n",
        "2015-03-02     4.0     5.0    11.0    19.0    10.0    16.0    22.0     2.0   \n",
        "2015-04-01    20.0     7.0    13.0     8.0     9.0    18.0     6.0     2.0   \n",
        "2015-05-04     6.0    16.0    15.0    24.0     9.0     2.0    13.0    18.0   \n",
        "2015-06-01    21.0     5.0    15.0     4.0    10.0    27.0    12.0     9.0   \n",
        "\n",
        "ticker      801130  801140   ...    801720  801730  801740  801750  801760  \\\n",
        "tradeDate                    ...                                             \n",
        "2015-02-02    25.0    23.0   ...       4.0    18.0    14.0    28.0    27.0   \n",
        "2015-03-02    15.0    20.0   ...      25.0    17.0     6.0    28.0    27.0   \n",
        "2015-04-01    24.0    22.0   ...      25.0    27.0     4.0    28.0    12.0   \n",
        "2015-05-04    19.0    20.0   ...      28.0    14.0    27.0     4.0    22.0   \n",
        "2015-06-01    24.0    26.0   ...       3.0    19.0    20.0    28.0    22.0   \n",
        "\n",
        "ticker      801770  801780  801790  801880  801890  \n",
        "tradeDate                                           \n",
        "2015-02-02    21.0     1.0     2.0    12.0    15.0  \n",
        "2015-03-02    26.0     1.0    21.0    24.0    14.0  \n",
        "2015-04-01    15.0     1.0     3.0    10.0    21.0  \n",
        "2015-05-04    21.0     7.0     1.0     5.0    23.0  \n",
        "2015-06-01    25.0     1.0     2.0    13.0    18.0  \n",
        "\n",
        "[5 rows x 28 columns]"
       ]
      }
     ]
    },
    {
     "cell_type": "markdown",
     "id": "EE05369BDC4D4186893CD854230C9FCD",
     "metadata": {},
     "source": [
      "## 2. \u884c\u4e1a\u6708\u5ea6\u6536\u76ca\u7387\u76f8\u5173\u6027\u5206\u6790\n",
      "----\n",
      "\u5c06\u6240\u6709\u7684\u884c\u4e1a\u6708\u5ea6\u6536\u76ca\u7387\u6392\u5e8f\u4e0e\u884c\u4e1a\u7684\u4e00\u9636\u6ede\u540e\u6708\u5ea6\u6536\u76ca\u7387\u6392\u5e8f\u505a\u76f8\u5173\u6027\u5206\u6790\u3002"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "801FB9F06293494ABE09A7384A15A240",
     "input": [
      "# \u62ff\u53d6\u7533\u4e07\u4e00\u7ea7\u884c\u4e1a\u6307\u6570\u4ee3\u7801\uff0c\u4e00\u517128\u4e2a\n",
      "index_symbol = DataAPI.IndustryGet(industryVersion=u\"SW\",industryVersionCD=u\"\",industryLevel=u\"1\",isNew=u\"1\",field=u\"\",pandas=\"1\")['indexSymbol'].tolist() \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "EA8CD8D95B0D445A963B3C9B3FE3C7BF",
     "input": [
      "def get_corr(ind1, ind2, df_ind):\n",
      "    \"\"\"\n",
      "    \u8fd4\u56de\u884c\u4e1a1\u4e0e\u884c\u4e1a2\u76841\u9636\u6ede\u540e\u7684\u76f8\u5173\u7cfb\u6570\n",
      "    Args:\n",
      "        ind1(str):\u884c\u4e1a\u6307\u6570\u4ee3\u7801\n",
      "        ind2(str)\uff1a\u884c\u4e1a\u6307\u6570\u4ee3\u7801\n",
      "        df_ind(DataFrame)\uff1a\u6240\u6709\u884c\u4e1a\u6307\u6570\u7684\u6708\u5ea6\u6536\u76ca\u8868\n",
      "    Returns:\n",
      "        numpy.float64: \u884c\u4e1a1\u4e0e\u884c\u4e1a2\u76841\u9636\u6ede\u540e\u7684\u76f8\u5173\u7cfb\u6570\n",
      "\n",
      "    Examples:\n",
      "        >> ind_corr  = get_corr('801760','801150',df_monthly_industry_return_rank)\n",
      "    \"\"\"\n",
      "    x = df_ind[ind1].iloc[0:-1].values\n",
      "    y = df_ind[ind2].iloc[1:].values\n",
      "    return np.corrcoef(x,y)[0][1]   #\u8fd4\u56de\u4e24\u7ec4\u6570\u636e\u7684\u76ae\u5c14\u68ee\u76f8\u5173\u7cfb\u6570"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "9D4E1535C1634CF5B49C0AA81EBFCD9D",
     "input": [
      "predict_corr = {} \n",
      "for item in itertools.product(index_symbol,repeat=2):         #\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u548c\u5269\u4f59\u6240\u6709\u7684\u5143\u7d20\u8fdb\u884c\u914d\u5bf9\n",
      "    predict_corr[item] = get_corr(item[0],item[1], df_monthly_industry_return_rank) # \u5f97\u5230\u884c\u4e1a\u6536\u76ca\u7387\u6392\u540d\u76f8\u5173\u7cfb\u6570\u5b57\u5178\n",
      "predict_corr = pd.Series(predict_corr) # \u5c06\u5b57\u5178\u8f6c\u5316\u4e3a\u5e8f\u5217"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "E20E5C8624784FE882B4DB9E936C8296",
     "input": [
      "predict_corr.hist() # \u505a\u51fa\u76f8\u5173\u7cfb\u6570\u7684\u9891\u6570\u76f4\u65b9\u56fe"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 98,
       "text": [
        "<matplotlib.axes._subplots.AxesSubplot at 0x3b117450>"
       ]
      },
      {
       "data": {
        "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe4AAAFXCAYAAABk0q3rAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH7RJREFUeJzt3XtwVPXh/vEnsGgFAgIbNinbppVMCu2CtmFgoJ3KBJoY\nYggJ4lQdvIAmznSIIEhLvFBqxRGKw3/OBlGK42VUEhWB4rBIGGyJw3qJO4AO+WIwwC4bInG5CYTz\n+4OfO0bALJvL2Q/7fv3FfvZcnnyM+2TPnj0nxbIsSwAAwAi97A4AAABiR3EDAGAQihsAAINQ3AAA\nGITiBgDAIBQ3AAAG6bC4KysrNWHCBBUVFUXH6uvrddttt2natGm67bbb9Nlnn0Wf83q9ysvLU0FB\ngXbs2NE9qQEASFIdFndpaalWr17dbmz58uWaO3eu3nrrLc2ZM0fLli2TJO3bt0+bNm3Sxo0btWrV\nKi1ZskR8TRwAgK7TYXGPGTNGAwYMaDc2dOhQRSIRSVIkEpHL5ZIkbd26VVOmTJHD4ZDb7VZmZqbq\n6+u7ITYAAMnJEc9K8+fP1x133KFnnnlGlmXptddekySFQiHddNNN0eVcLpdCoVDXJAUAAPEV96OP\nPqrHH39ckydP1n/+8x9VVlbqxRdfjCvA6dOnFQgElJaWpt69e8e1DQAATNLW1qZwOCyPx6Of/OQn\nV7RuXMX96aefRov6lltu0WOPPSbpwjvsw4cPR5cLBoPRw+iXEwgEdNddd8UTAwAAo7388ssaM2bM\nFa0TU3H/8ASzX/ziF/rwww81duxY/e9//1NmZqYkKTc3VwsWLNC9996rUCikAwcOaPTo0T+67bS0\ntGj49PT0KwqfjAKBgDwej90xEh7zFDvmKjbMU2yYp9gEg0Hddddd0Q68Eh0W9/z581VXV6djx45p\n4sSJmjNnjv7xj39oyZIlOnv2rK699lo9+eSTkqSsrCwVFBSosLBQDodDixcvVkpKyo9u/7vD4+np\n6XK73Vf8AySbUCjEPMWAeYodcxUb5ik2zNOVi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3aPqa2ttfLy8qw/\n/elPltfrtSzLsl599VXrtddeiy6zZMkSa/LkyVZRUZEVCATsimq7jubq0UcftcaOHWtNmzbNKi4u\ntqZPn25nXNvE8jv1nb/97W9JeVa5ZcU2T88//7w1ZcoU69Zbb7XWrl3b4Ta5VjkAAAbhymkAABiE\n4gYAwCAUNwAABqG4AQAwCMUNAIBBKG4AAAxCcQMAYBCKGwAAg/w/lJfR5a7XZ8YAAAAASUVORK5C\nYII=\n",
        "text/plain": "<matplotlib.figure.Figure at 0x66030550>"
       },
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAe4AAAFXCAYAAABk0q3rAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH7RJREFUeJzt3XtwVPXh/vEnsGgFAgIbNinbppVMCu2CtmFgoJ3KBJoY\nYggJ4lQdvIAmznSIIEhLvFBqxRGKw3/OBlGK42VUEhWB4rBIGGyJw3qJO4AO+WIwwC4bInG5CYTz\n+4OfO0bALJvL2Q/7fv3FfvZcnnyM+2TPnj0nxbIsSwAAwAi97A4AAABiR3EDAGAQihsAAINQ3AAA\nGITiBgDAIBQ3AAAG6bC4KysrNWHCBBUVFUXH6uvrddttt2natGm67bbb9Nlnn0Wf83q9ysvLU0FB\ngXbs2NE9qQEASFIdFndpaalWr17dbmz58uWaO3eu3nrrLc2ZM0fLli2TJO3bt0+bNm3Sxo0btWrV\nKi1ZskR8TRwAgK7TYXGPGTNGAwYMaDc2dOhQRSIRSVIkEpHL5ZIkbd26VVOmTJHD4ZDb7VZmZqbq\n6+u7ITYAAMnJEc9K8+fP1x133KFnnnlGlmXptddekySFQiHddNNN0eVcLpdCoVDXJAUAAPEV96OP\nPqrHH39ckydP1n/+8x9VVlbqxRdfjCvA6dOnFQgElJaWpt69e8e1DQAATNLW1qZwOCyPx6Of/OQn\nV7RuXMX96aefRov6lltu0WOPPSbpwjvsw4cPR5cLBoPRw+iXEwgEdNddd8UT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srJSWVlZuueee3oynq2+f++AM2fOaMOGDRfNz6RJk6KH6D755BMNGDAg+tFDMoll\nrg4dOqSKigotW7ZMP//5z21Kaq9Y5snn88nn82nr1q265ZZbtHjx4qQqbSn2//f8fr/a2tp06tQp\n1dfXd9x13XAiXYe+/vpr65577rHy8vKs++67z2ptbbUsy7JCoZBVVlYWXW7Pnj1WaWmpNXXqVOsv\nf/lL9EzOZBLrXH2nrq4uKc8qj2Wedu3aZY0YMcKaOnWqVVxcbE2bNs2qra21M3aPqa2ttfLy8qw/\n/elPltfrtSzLsl599VXrtddeiy6zZMkSa/LkyVZRUZEVCATsimq7jubq0UcftcaOHWtNmzbNKi4u\ntqZPn25nXNvE8jv1nb/97W9JeVa5ZcU2T88//7w1ZcoU69Zbb7XWrl3b4Ta5VjkAAAbhymkAABiE\n4gYAwCAUNwAABqG4AQAwCMUNAIBBKG4AAAxCcQMAYBCKGwAAg/w/lJfR5a7XZ8YAAAAASUVORK5C\nYII=\n",
       "source": "display",
       "text": [
        "<matplotlib.figure.Figure at 0x66030550>"
       ]
      }
     ]
    },
    {
     "cell_type": "markdown",
     "id": "3E8FA9B46CB345768CBB9FA7129EE876",
     "metadata": {},
     "source": [
      "\u53ef\u4ee5\u770b\u51fa\u884c\u4e1a\u4e0e\u884c\u4e1a\u7684\u4e00\u9636\u6ede\u540e\u7684\u76f8\u5173\u6027\u5e76\u4e0d\u9ad8\uff0c\u5927\u90e8\u5206\u7ef4\u6301\u57280\u9644\u8fd1\uff0c\u6211\u4eec\u8981\u627e\u51fa\u90a3\u4e9b\u76f8\u5173\u7cfb\u6570\u5728\u7edf\u8ba1\u4e0a\u662f\u663e\u8457\u7684\u4e24\u4e2a\u884c\u4e1a\u3002\u76f8\u5173\u7cfb\u6570\u4e0d\u7b49\u4e8e0\u7684\u663e\u8457\u6027\u68c0\u9a8c\u91cf\u4e3a\uff1a\n",
      "$$ t = \\frac{r\\sqrt{n-2}}{\\sqrt{1-r^2}}  ,df = n-2$$\n",
      "\u67e5\u9605$t$\u5206\u5e03\u8868,$t_{(36)0.01} = 2.728$,\u53cd\u63a8\u51fa$|r|=0.43$,\u5373\u5f53$|r|>0.43$\u65f6,\u572899%\u7f6e\u4fe1\u6c34\u5e73\u662f\u7edf\u8ba1\u4e0a\u663e\u8457\u7684\u3002\u6545\u6211\u4eec\u7b5b\u9009\u51fa\u5927\u4e8e0.43\u6216\u5c0f\u4e8e-0.43\u65f6\u7684\u884c\u4e1a\u76f8\u5173\u6027\u3002"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "7EB1DDAB1E374B26981F415B353F95CA",
     "input": [
      "filter_corr = predict_corr[(predict_corr>0.43) | (predict_corr<-0.43)]\n",
      "tem = pd.DataFrame(filter_corr.sort_values(ascending=0)).reset_index()\n",
      "tem.columns = ['ind1','ind2','corr']\n",
      "tem"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th></th>\n",
        "      <th>ind1</th>\n",
        "      <th>ind2</th>\n",
        "      <th>corr</th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>0</th>\n",
        "      <td>801760</td>\n",
        "      <td>801140</td>\n",
        "      <td>0.527449</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1</th>\n",
        "      <td>801080</td>\n",
        "      <td>801110</td>\n",
        "      <td>0.523264</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2</th>\n",
        "      <td>801740</td>\n",
        "      <td>801140</td>\n",
        "      <td>0.460587</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>3</th>\n",
        "      <td>801130</td>\n",
        "      <td>801130</td>\n",
        "      <td>0.458688</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>4</th>\n",
        "      <td>801740</td>\n",
        "      <td>801230</td>\n",
        "      <td>0.436172</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>5</th>\n",
        "      <td>801010</td>\n",
        "      <td>801740</td>\n",
        "      <td>0.431786</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>6</th>\n",
        "      <td>801730</td>\n",
        "      <td>801710</td>\n",
        "      <td>-0.440035</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>7</th>\n",
        "      <td>801200</td>\n",
        "      <td>801120</td>\n",
        "      <td>-0.468657</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>8</th>\n",
        "      <td>801120</td>\n",
        "      <td>801130</td>\n",
        "      <td>-0.516949</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 99,
       "text": [
        "     ind1    ind2      corr\n",
        "0  801760  801140  0.527449\n",
        "1  801080  801110  0.523264\n",
        "2  801740  801140  0.460587\n",
        "3  801130  801130  0.458688\n",
        "4  801740  801230  0.436172\n",
        "5  801010  801740  0.431786\n",
        "6  801730  801710 -0.440035\n",
        "7  801200  801120 -0.468657\n",
        "8  801120  801130 -0.516949"
       ]
      }
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "216946BA5B85441F874954C6FD741E6C",
     "input": [
      "def get_ind_name(tickers):\n",
      "    \"\"\"\n",
      "    \u8fd4\u56de\u884c\u4e1a\u4ee3\u7801\u5bf9\u5e94\u7684\u884c\u4e1a\u540d\u79f0\n",
      "    Args:\n",
      "        tickers(list):\u884c\u4e1a\u4ee3\u7801\u5217\u8868\n",
      "    Returns:\n",
      "        DataFrame: \u4e00\u5217\u884c\u4e1a\u4ee3\u7801\u4e00\u5217\u884c\u4e1a\u540d\u79f0\u7ec4\u6210\u7684DataFrame\n",
      "\n",
      "    Examples:\n",
      "        >> symbol_name  = get_ind_name([801030,801120,801130,801170])\n",
      "    \"\"\"\n",
      "    symbol_name = DataAPI.IndustryGet(industryVersion=u\"SW\",industryVersionCD=u\"\",industryLevel=u\"1\",isNew=u\"1\",\n",
      "                                       field=u\"indexSymbol,industryName\",pandas=\"1\")\n",
      "    return symbol_name[symbol_name['indexSymbol'].isin(tickers)]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "id": "FD183A8AF67147CB8522E3DB4D8362A2",
     "input": [
      "ind1_dict = get_ind_name(tem.ind1).set_index('indexSymbol').industryName.to_dict()    #\u4e00\u5b9a\u6ce8\u610f\u662f\u5b57\u7b26\uff01\uff01\uff01\n",
      "ind2_dict = get_ind_name(tem.ind2).set_index('indexSymbol').industryName.to_dict()    #\u4e00\u5b9a\u6ce8\u610f\u662f\u5b57\u7b26\uff01\uff01\uff01\n",
      "tem['ind1'] = tem.ind1.map(ind1_dict)\n",
      "tem['ind2'] = tem.ind2.map(ind2_dict)\n",
      "tem"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th></th>\n",
        "      <th>ind1</th>\n",
        "      <th>ind2</th>\n",
        "      <th>corr</th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>0</th>\n",
        "      <td>\u4f20\u5a92</td>\n",
        "      <td>\u8f7b\u5de5\u5236\u9020</td>\n",
        "      <td>0.527449</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1</th>\n",
        "      <td>\u7535\u5b50</td>\n",
        "      <td>\u5bb6\u7528\u7535\u5668</td>\n",
        "      <td>0.523264</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>2</th>\n",
        "      <td>\u56fd\u9632\u519b\u5de5</td>\n",
        "      <td>\u8f7b\u5de5\u5236\u9020</td>\n",
        "      <td>0.460587</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>3</th>\n",
        "      <td>\u7eba\u7ec7\u670d\u88c5</td>\n",
        "      <td>\u7eba\u7ec7\u670d\u88c5</td>\n",
        "      <td>0.458688</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>4</th>\n",
        "      <td>\u56fd\u9632\u519b\u5de5</td>\n",
        "      <td>\u7efc\u5408</td>\n",
        "      <td>0.436172</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>5</th>\n",
        "      <td>\u519c\u6797\u7267\u6e14</td>\n",
        "      <td>\u56fd\u9632\u519b\u5de5</td>\n",
        "      <td>0.431786</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>6</th>\n",
        "      <td>\u7535\u6c14\u8bbe\u5907</td>\n",
        "      <td>\u5efa\u7b51\u6750\u6599</td>\n",
        "      <td>-0.440035</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>7</th>\n",
        "      <td>\u5546\u4e1a\u8d38\u6613</td>\n",
        "      <td>\u98df\u54c1\u996e\u6599</td>\n",
        "      <td>-0.468657</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>8</th>\n",
        "      <td>\u98df\u54c1\u996e\u6599</td>\n",
        "      <td>\u7eba\u7ec7\u670d\u88c5</td>\n",
        "      <td>-0.516949</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "</div>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 102,
       "text": [
        "   ind1  ind2      corr\n",
        "0    \u4f20\u5a92  \u8f7b\u5de5\u5236\u9020  0.527449\n",
        "1    \u7535\u5b50  \u5bb6\u7528\u7535\u5668  0.523264\n",
        "2  \u56fd\u9632\u519b\u5de5  \u8f7b\u5de5\u5236\u9020  0.460587\n",
        "3  \u7eba\u7ec7\u670d\u88c5  \u7eba\u7ec7\u670d\u88c5  0.458688\n",
        "4  \u56fd\u9632\u519b\u5de5    \u7efc\u5408  0.436172\n",
        "5  \u519c\u6797\u7267\u6e14  \u56fd\u9632\u519b\u5de5  0.431786\n",
        "6  \u7535\u6c14\u8bbe\u5907  \u5efa\u7b51\u6750\u6599 -0.440035\n",
        "7  \u5546\u4e1a\u8d38\u6613  \u98df\u54c1\u996e\u6599 -0.468657\n",
        "8  \u98df\u54c1\u996e\u6599  \u7eba\u7ec7\u670d\u88c5 -0.516949"
       ]
      }
     ]
    }
   ],
   "metadata": {}
  }
 ]
}